package com.sfx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sfx.domain.ResponseResult;
import com.sfx.domain.vo.LinkVo;
import com.sfx.utils.BeanCopyUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sfx.domain.entity.Link;
import com.sfx.mapper.LinkMapper;
import com.sfx.service.LinkService;

import static com.sfx.constants.SystemConstants.LINK_STATUS_PASS;

/**
* Created with IntelliJ IDEA.
* Description:
* User: sfx
* Date: 2023-07-11
* Time: 11:32
*/
@Service
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService{
    /**
     * 友联查询
     * 在友链页面要查询出所有的审核通过的友链。
     * @return
     */
    @Override
    public ResponseResult getAllLink() {
        LambdaQueryWrapper<Link> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Link::getStatus, LINK_STATUS_PASS);
        List<Link> list = list(queryWrapper);
        List<LinkVo> linkVos = BeanCopyUtils.copyBeanList(list, LinkVo.class);
        return ResponseResult.okResult(linkVos);
    }
}